package com.baizhi.service.impl;

import com.baizhi.dao.AdminLogDAO;
import com.baizhi.entity.AdminLog;
import com.baizhi.service.AdminLogService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdminLogServiceImpl implements AdminLogService {
    @Autowired
    private AdminLogDAO adminLogDAO;
    @Override
    public PageInfo<AdminLog> selectAll(Integer page, Integer limit) {
        PageHelper.startPage(page,limit);
        List<AdminLog> adminLogs = adminLogDAO.selectAll();
        PageInfo<AdminLog> pageInfo = new PageInfo<>(adminLogs);
        return pageInfo;
    }

    @Override
    public Boolean insertAdminLog(AdminLog adminLog) {
        Boolean a = null;
        try{
            adminLogDAO.insertAdminLog(adminLog);
            a = true;
        }catch(Exception e){
            e.printStackTrace();
            a = false;
        }
        return a;
    }

    @Override
    public Boolean deleteAdminLogAll(Integer[] ids) {
        Boolean a = null;
        try {
            adminLogDAO.deleteAdminLogAll(ids);
            a = true;
        } catch (Exception e) {
            e.printStackTrace();
            a = false;
        }
        return a;
    }
}
